import request from '@/utils/request';

export async function queryStatisticsList() {
  return request('/hk/admin/statistics/perpetualContract', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: localStorage.getItem("StatisticsListParamId") === '全部' ? {} : {id: localStorage.getItem("StatisticsListParamId")}
    },
  });
}

export async function queryGoodsList() {
  return request('/hk/admin/statistics/goodsProfit', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: localStorage.getItem("GoodsListParamId") === '全部' ? {} : {id: localStorage.getItem("GoodsListParamId")}
    },
  });
}

export async function queryGoodsGrid() {
  return request('/hk/admin/statistics/spotGridProfit', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: localStorage.getItem("GoodsGridParamId") === '全部' ? {} : {id: localStorage.getItem("GoodsGridParamId")}
    },
  });
}

export async function queryUProfit(params: any) {
  let p: any = localStorage.getItem("UProfitParamId") === '全部' ? {} : {adminId: localStorage.getItem("UProfitParamId")};
  if (params.dateS) {
    p.startTime = new Date(params.dateS + " 00:00:00").getTime();
  }
   if (params.dateE) {
    p.endTime = new Date(params.dateE + " 00:00:00").getTime();
  }
  return request('/hk/admin/statistics/uContractProfit', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: p,
    },
  });
}


export async function queryFTXdHedging(params: any) {
  let p: any = localStorage.getItem("FTXdHedgingParamId") === '全部' ? {} : {adminId: localStorage.getItem("FTXdHedgingParamId")};
  if (params.dateS) {
    p.startTime = new Date(params.dateS + " 00:00:00").getTime();
  }
   if (params.dateE) {
    p.endTime = new Date(params.dateE + " 00:00:00").getTime();
  }
  return request('/hk/admin/ftx/statistics/contractHedging', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },

    data: {
      debug: true,
      param: p,
    },
  });
}

export async function queryLiquidityList() {
  return request('/hk/admin/statistics/liquiditySwap', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: localStorage.getItem("LiquidityListParamId") === '全部' ? {} : {id: localStorage.getItem("LiquidityListParamId")}
    },
  });
}


export async function queryUesrList(userType: number) {
  return await request('/hk/admin/list', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: {userType: userType}
    },
  });
}

export async function queryOverview(date: string | undefined | null) {
  return await request('/hk/admin/statistics/overview', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: {start: date ? new Date(date + " 00:00:00").getTime() : null}
    },
  });
}


export async function queryGridProfit(date: string | undefined | null) {
  return await request('/hk/admin/statistics/gridProfit', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: localStorage.getItem("GridProfitParamId") === '全部' ? {
          start: date ? new Date(date + " 00:00:00").getTime() : null,
        } :
        {
          start: date ? new Date(date + " 00:00:00").getTime() : null,
          id: localStorage.getItem("GridProfitParamId")
        }
    },
  });
}

export async function queryGridProfitCurve(id: string) {
  return await request('/hk/admin/statistics/gridProfitCurve', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: {
        id: id,
      }
    },
  });
}


export async function queryGridProfitCurveSum(ids: []) {
  return await request('/hk/admin/statistics/batchGridProfitCurve', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: {
        ids: ids,
      }
    },
  });
}


export async function queryContractArbitrage() {
  return request('/hk/admin/ftx/statistics/contractArbitrage', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: localStorage.getItem("FTXParamId") === '全部' ? {} : {id: localStorage.getItem("FTXParamId")}
    },
  });
}


export async function queryHedgeProfit(date: string | undefined | null) {
  return await request('/hk/admin/statistics/hedgingProfit', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: localStorage.getItem("HedgeProfitParamId") === '全部' ? {
          start: date ? new Date(date + " 00:00:00").getTime() : null,
        } :
        {
          start: date ? new Date(date + " 00:00:00").getTime() : null,
          // id: 21
          id: localStorage.getItem("HedgeProfitParamId")
        }
    },
  });
}

export async function queryHedgeProfitCurve(id: string) {
  return await request('/hk/admin/statistics/hedgingProfitCurve', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: {
        id: id,
      }
    },
  });
}

export async function queryHedgeProfitCurveSum(ids: []) {
  return await request('/hk/admin/statistics/batchHedgingProfitCurve', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: {
        ids: ids,
      }
    },
  });
}


export async function querySimilarPairProfit(date: string | undefined | null) {
  return await request('/hk/admin/statistics/similarPairProfit', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: localStorage.getItem("SimilarPairProfitParamId") === '全部' ? {
          start: date ? new Date(date + " 00:00:00").getTime() : null,
        } :
        {
          start: date ? new Date(date + " 00:00:00").getTime() : null,
          id: localStorage.getItem("SimilarPairProfitParamId")
        }
    },
  });
}

export async function querySimilarPairProfitCurve(id: string) {
  return await request('/hk/admin/statistics/similarPairProfitCurve', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: {
        id: id,
      }
    },
  });
}

export async function querySimilarPairProfitCurveSum(ids: []) {
  return await request('/hk/admin/statistics/batchSimilarPairProfitCurve', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },
    data: {
      debug: true,
      param: {
        ids: ids,
      }
    },
  });
}


export async function queryDeribiteQuityLogs() {
  return await request('/hk/admin/deribit/statistics/equityLogs', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'token': `${localStorage.getItem('token')}`
    },

  });
}

